import mongoose from "mongoose";
import { app } from "./app"

const start = async () => {
	if (!process.env.JWT_KEY) throw new Error("JWT_KEY 系统变量获取失败");
	if (!process.env.MONGO_URI) throw new Error("MONGO_URI 系统变量获取失败");
	try {
		await mongoose.connect(process.env.MONGO_URI);
		console.log("连接到mongodb数据");
	} catch (err) {
		console.error(err);
	}

	app.listen(3000, () => {
		console.log("服务启动 端口:3000 😀");
	});
};


start();
